﻿@model Back_end.Models.Complaint

@{
	ViewBag.Title = "编辑";
	var pp = Model.PicturePath == null ? "" : Model.PicturePath;
	var tp = Model.Tag == null ? "" : Model.Tag;
	var pps = pp.Split('|');
	var tps = tp.Split('|');
}

<h2>@ViewBag.Title </h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
		<p>共 @ViewBag.Followed 人关注，@ViewBag.Liked 人赞同</p>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ComplaintId)
        @Html.HiddenFor(model => model.UserName)
        @Html.HiddenFor(model => model.PublishedDate)
        @Html.HiddenFor(model => model.Text)
        @Html.HiddenFor(model => model.PicturePath)
        @Html.HiddenFor(model => model.Location)
		@Html.HiddenFor(model => model.Coordinate)
        @Html.HiddenFor(model => model.Tag)

        <div class="form-group">
            @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PublishedDate, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayFor(model => model.PublishedDate, new { htmlAttributes = new { @class = "form-control" } })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Text, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayFor(model => model.Text, new { htmlAttributes = new { @class = "form-control" } })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PicturePath, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @foreach (var path in pps)
				{ <img src=@path class="img-thumbnail col-md-4"> }
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Location, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayFor(model => model.Location, new { htmlAttributes = new { @class = "form-control" } })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Tag, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @foreach (var tag in tps)
				{ <span class="label label-info" style="margin-right:10px">@tag </span> }
            </div>
        </div>

		<div class="form-group">
			@Html.LabelFor(model => model.Company, htmlAttributes: new { @class = "control-label col-md-2" })
			<div class="col-md-10">
				@Html.HiddenFor(model => model.Company)
				@Html.DisplayFor(model => model.Company, new { htmlAttributes = new { @class = "form-control" } })
			</div>
		</div>

        <div class="form-group">
            @Html.LabelFor(model => model.AllowedPublished, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
					@if (Model.AllowedPublished == null)
					{
						@Html.DropDownListFor(model => model.AllowedPublished,
				 new List<SelectListItem> {
										new SelectListItem() { Text = "未审核", Value = (null as bool?).ToString() },
										new SelectListItem() { Text = "已通过", Value = "true" },
										new SelectListItem() { Text = "未通过", Value = "false" }
									})
					}
					else
					{
						@Html.HiddenFor(model => model.AllowedPublished)
						var allow = Model.AllowedPublished == true ? "已审核" : "未通过";
						@allow
					}
                    @Html.ValidationMessageFor(model => model.AllowedPublished, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.HadProcessed, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
					@if (Model.HadProcessed == true)
					{
						@Html.HiddenFor(model => model.HadProcessed)
						<text>已处理</text>
					}
					else
					{
						@Html.DropDownListFor(model => model.HadProcessed,
				 new List<SelectListItem> {
										new SelectListItem() { Text = "未处理", Value = (null as bool?).ToString() },
										new SelectListItem() { Text = "已处理", Value = "true" },
										new SelectListItem() { Text = "处理中", Value = "false" }
									})
					}
                    @Html.ValidationMessageFor(model => model.HadProcessed, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Review, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
				@if (Model.HadProcessed == true)
				{
					@Html.HiddenFor(model => model.Review)
					@Html.DisplayFor(model => model.Review)
				}
				else
				{
					@Html.EditorFor(model => model.Review, new { htmlAttributes = new { @class = "form-control" } })
				}
                @Html.ValidationMessageFor(model => model.Review, "", new { @class = "text-danger" })
            </div>
        </div>

		@if (Model.Review == null)
        {
			<div class="form-group">
				<div class="col-md-offset-2 col-md-10">
					<input type = "submit" value="Save" class="btn btn-default" />
				</div>
			</div>	
		}
    </div>
}

<div>
    @Html.ActionLink("返回列表", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
